package Testhandle_db;

import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;

import java.util.ArrayList;

import java.util.Date;

import handle_db.User_DB_Connector;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

import entities.*;


public class User_DB_ConnectorTest {
	@BeforeClass
	public static void setUpBeforeClass() throws Exception {
		System.out.println("Before class");
	}

	@AfterClass
	public static void tearDownAfterClass() throws Exception {
		System.out.println("After class");
	}

	@Before
	public void setUp() throws Exception {
		System.out.println("Before");
	}
	@Test
	public void testGetUser(){
		User_DB_Connector user=new User_DB_Connector();
		User u=new User();
		u.setUser_id("1");
		u.setUser_name("jack");
		u.setUser_number(1);
		
		String[] tag=new String[10];
		tag[0]="basketball";
		tag[1]="badmintan";
		u.setTag_list(tag);
		
		Group g1=new Group();
		g1.setGroup_name("friend");
		g1.setGroup_size(3);
		ArrayList<Integer> friend=new ArrayList<Integer>();
		friend.add(1);
		friend.add(2);
		friend.add(3);
		g1.setGroup_member(friend);
		ArrayList<Group> g=new ArrayList<Group>();
		g.add(g1);
		u.setFriends(g);
		
		u.setUser_password("00");
		u.setUser_sex(0);
		u.setUser_type(0);

		State s=new State();
		s.setTitle("mytest");
		u.setCurrent_state(s);
		
//		Date d=new Date();
//		Calendar c=new Calendar();
//		c.setDate(d);
//		ArrayList<Calendar> cl=new ArrayList<Calendar>();
//		cl.add(c);
//		u.setMy_calendar(cl);
		
		user.add_User(u);
		
		User a=user.get_User(1);

		assertThat(a.equals(u),is(true));
		assertThat(a.getFriends().equals(g),is(true));
		assertThat(a.getCurrent_state().equals(s),is(true));
		//assertThat(a.getMy_calendar(),is(cl));
		
		//user.delete_User(1);
	}
	
	@After
	public void tearDown() throws Exception {
		System.out.println("After");
	}
}
